package Array;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Created by joel on 2018/7/9.国际摩尔斯密码定义一种标准编码方式，将每个字母对应于一个由一系列点和短线组成的字符串， 比如: "a" 对应 ".-", "b" 对应 "-...", "c" 对应 "-.-.", 等等。

 为了方便，所有26个英文字母对应摩尔斯密码表如下：

 [".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."]
 给定一个单词列表，每个单词可以写成每个字母对应摩尔斯密码的组合。例如，"cab" 可以写成 "-.-.-....-"，(即 "-.-." + "-..." + ".-"字符串的结合)。我们将这样一个连接过程称作单词翻译。

 返回我们可以获得所有词不同单词翻译的数量。

 例如:
 输入: words = ["gin", "zen", "gig", "msg"]
 输出: 2
 解释:
 各单词翻译如下:
 "gin" -> "--...-."
 "zen" -> "--...-."
 "gig" -> "--...--."
 "msg" -> "--...--."

 共有 2 种不同翻译, "--...-." 和 "--...--.".


 注意:

 单词列表words 的长度不会超过 100。
 每个单词 words[i]的长度范围为 [1, 12]。
 每个单词 words[i]只包含小写字母。
 */
public class UniqueMorseCodeWords {
    static HashMap<Character, String> map = new HashMap<>();

    static {
        String[] values = new String[]{".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-                                           ",".-.","...","-","..-","...-",".--","-..-","-.--","--.."};
        for (int i = 0; i < values.length; i++) {
            map.put((char)('a'+i), values[i]);
        }
    }
    public int uniqueMorseRepresentations(String[] words) {
        List<String> res = new ArrayList<>();
        for (String word: words) {
            res.add(uniqueMorse(word));
        }
        return res.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).size();

    }
    public String uniqueMorse(String str) {
        String res = "";
        for (int i = 0; i < str.length(); i++) {
            res = res + map.get(str.charAt(i));
        }
        return res;
    }
}
public class MainClass {
    public static String[] stringToStringArray(String input) {
        JsonArray jsonArray = JsonArray.readFrom(line);
        String[] arr = new String[jsonArray.size()];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = jsonArray.get(i).asString();
        }
        return arr;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            String[] words = stringToStringArray(line);

            int ret = new UniqueMorseCodeWords().uniqueMorseRepresentations(words);

            String out = String.valueOf(ret);

            System.out.print(out);
        }
    }
}